package com.example.backend.dto;

import lombok.Data;

import java.util.List;

/**
 * 分页结果DTO
 */
@Data
public class PageResult<T> {
    private List<T> content;
    private int page;
    private int size;
    private long totalElements;
    private int totalPages;
    private boolean first;
    private boolean last;
    private boolean hasNext;
    private boolean hasPrevious;
    
    public PageResult() {}
    
    public static <T> PageResult<T> of(org.springframework.data.domain.Page<T> page) {
        PageResult<T> result = new PageResult<>();
        result.content = page.getContent();
        result.page = page.getNumber();
        result.size = page.getSize();
        result.totalElements = page.getTotalElements();
        result.totalPages = page.getTotalPages();
        result.first = page.isFirst();
        result.last = page.isLast();
        result.hasNext = page.hasNext();
        result.hasPrevious = page.hasPrevious();
        return result;
    }
}
